<?php
namespace App\Models;
use Illuminate\Support\Facades\DB;

class ShopGoodsStock extends CommonModel {
	protected $table = 'shop_goods_sale';

    //增加销量
    public function addSaleNumber($goods_id,$goods_type,$goods_number){
        return self::where(['goods_id'=>$goods_id,'goods_type'=>$goods_type])->increment('sale_num',$goods_number);
    }
    //减少销量
    public function delSaleNumber($goods_id,$goods_type,$goods_number){
        return self::where(['goods_id'=>$goods_id,'goods_type'=>$goods_type])->decrement('sale_num',$goods_number);
    }
    //增加商品流量
    public function addGoodsView($goods_id,$goods_type){
        return self::where(['goods_id'=>$goods_id,'goods_type'=>$goods_type])->increment('view_num');
    }
}